package pp;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int l = scanner.nextInt();
        int m = scanner.nextInt();

        boolean[] trees = new boolean[l + 1];
        for (int i = 0; i < m; i++) {
      
            int u = scanner.nextInt();
            int v = scanner.nextInt();

            for (int j = u; j <= v; j++) {
                trees[j] = true;
            }
        }
        int remaining = 0;

        for (int i = 0; i <= l; i++) {
            if (!trees[i]) {
                remaining++;
            }
        }
        System.out.println(remaining);
        scanner.close();
    }
}